Skip to content

Release v5.0.1#28

Merged
mikebarkmin merged 1 commit into
mainfrom
changeset
Jul 21, 2026
Merged

Release v5.0.1#28
mikebarkmin merged 1 commit into
mainfrom
changeset

Conversation

@github-actions

Copy link
Copy Markdown

Make stages with hundreds of sprites run at a usable frame rate.

Four things were costing more than they had to, all of them growing with the
number of sprites:

  • Every sprite's costume ended its draw with resetShader(), which flushes the
    renderer. That turned what could be a few batched draw calls into one per
    sprite. The shader is now only reset when one was actually set.
  • getHitbox() rebuilt the sprite's collision shape from scratch on every call,
    and collision checks call it once per pair - so a stage with 200 sprites built
    40,000 shapes a frame. A sprite that has not moved, turned, resized or changed
    costume now reuses the shape it had.
  • Shape.intersects compared two outlines by building a java.awt.geom.Area for
    each. Sprite hitboxes are convex, so they are now compared with separating
    axes instead, which gives the same answer about 30x faster.
  • Building a Polygon from a list of corners rebuilt its path once per corner.

A benchmark of 200 sprites moving, bouncing off the edges and checking collisions
against each other every frame went from 96ms per frame to 25ms.

@mikebarkmin
mikebarkmin merged commit 4e7d663 into main Jul 21, 2026
@github-actions
github-actions Bot deleted the changeset branch July 21, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant